<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function batchfactoryExpress() {
    var winWidth = window.screen.width;
    var winHeight = window.screen.height;
    var newWidth = 1000;
    var newHeight = 750;
    var url = "/factory/ajaxbutton?op=batchfactoryExpress";
    window.open(url, '_blank', 'height=' + newHeight + ',width=' + newWidth + ',top=10,left=' + (winWidth - newWidth) / 2 + ',toolbar=no,menubar=no,scrollbars=yes,resizable=no,loocation=no,status=no');
}
function showmabangorder(id)
{
	if(id)
	{
		$.post("/factory/ajaxbutton", {"op": "showscanorder","id":id},
	  function(data){
			if(data.id)
			{
				$("#insttime").val(data.settlementtime);
				$("#order_id").val(data.order_id);	
				$("#goods_sku").val(data.goods_sku);	
				$("#specifications").val(data.specifications);	
				$("#goods_num").val(data.goods_num);	
				if(data.factoryID==2)
				{
					$("#fIDs").val(13);	
				}else{
					$("#fIDs").val(12);	
				}
				$("#scanid").val(data.id);	
			}
	   },"json");
	}
	$('#showmabangorder').modal('show');	
}
function atmangban()
{
	var insttime = $("#insttime").val();
	if(insttime=="")
	{
		alert("请输入日期！");
		return;	
	}
	var order_id = $("#order_id").val();
	if(order_id=="")
	{
		alert("请输入订单号！");
		return;	
	}
	var goods_sku = $("#goods_sku").val();
	if(goods_sku=="")
	{
		alert("请输入SKU！");
		return;	
	}
	var specifications = $("#specifications").val();
	if(specifications=="")
	{
		alert("请输入尺码！");
		return;	
	}
	var goods_num = $("#goods_num").val();
	if(goods_num=="")
	{
		alert("请输入数量！");
		return;	
	}
	var fID = $("#fIDs").val();
	if(fID=="")
	{
		alert("请选择工厂！");
		return;	
	}
	
	var insttime = $("#insttime").val();
	var order_id = $("#order_id").val();
	var goods_sku = $("#goods_sku").val();
	var specifications = $("#specifications").val();
	var goods_num = $("#goods_num").val();
	var scanid =  $("#scanid").val();
	
	$.post("/factory/ajaxbutton", {"op": "savescanorder","insttime":insttime,"order_id":order_id,"goods_sku":goods_sku,"specifications":specifications,"goods_num":goods_num,"fID":fID,"scanid":scanid},
	  function(data){
			if(data==200)
			{
				window.location.reload();	
			}
	   },"text");
}
function ouputcsv()
	{
	
		$("#if_csv").val(1);
		$("#search").attr("target","_thank");
		$("#search").submit();
		
	}
function deletesanorder(id)
{
	if(confirm("确定移除?"))
	{
		$.post("/factory/ajaxbutton", {"op": "deletesanorder","id":id},
		  function(data){
				
				document.location.href = "/factory/scanorder";
				return;
			
				
			return;
		   },"json");
	}	
}
</script>
<title>工厂扫件记录</title>
<body class="withvernav">
<div class="bodywrapper">
{{include file='/public/leftmenu.tpl'}}
<div class="centercontent">
<div class="pageheader notab">
  <h1 class="pagetitle">工厂扫件记录</h1>
  <span class="pagedesc"></span>
  <div class="menulist">
    <ul>
      <ul class="profile_summary">
         
         <li> <a href="javascript:void(0)" onClick="batchfactoryExpress()"><span>单件扫单</span></a></li>
         <li> <a href="javascript:void(0)" onClick="showmabangorder(0)"><span>批量订单</span></a></li>
		<li><a href="/factory/ajaxbutton?op=goodsReceiptList"><span>收件对帐列表</span></a></li>
      </ul>
    </ul>
  </div>
</div>
<!--pageheader-->
<div id="contentwrapper" class="contentwrapper">
  <div id="basicform" class="subcontent"> 
    <!--搜索栏-->
    <div>
      <div style="clear: both"></div>
      <div style="float:left">
       {{if $managers || in_array('104',$showpower)}}
        <button onClick="ouputcsv()"  class="stdbtn btn_black">订单导出</button>
        {{/if}}
      </div>
      <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
    </div>
   <form class="stdform stdform2" method="get" id="search" action="/factory/scanorder">
      <input type='hidden' name='if_csv' id='if_csv'>
      <div class="tableoptions">
        <select name="fID" id="fID"  class="selection " style="width:100px;" >
          <option value="" >工厂</option>
          <option value="12" {{if 12==$fID}} selected{{/if}}>工厂1</option>
          <option value="13" {{if 13==$fID}} selected{{/if}}>工厂2</option>
        </select>
       
        <select name="ty" id="searchtype" class="selection" style="width:100px;" >
         <option value="0">类型</option>
          <option value="1" {{if $ty==1}} selected{{/if}}>定制订单</option>
          <option value="2" {{if $ty==2}} selected{{/if}}>批量订单</option>
        </select>
        
         <select name="sts" id="sts" class="selection" style="width:100px;" >
          <option value="1" {{if $sts==1}} selected{{/if}}>操作时间</option>
          <option value="2" {{if $sts==2}} selected{{/if}}>清算日期</option>
        </select>
        <input type="text"  name="starttime" value="{{$starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
        -
        <input type="text"  name="endtime" value="{{$endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
        其他:
        <input type="text" name="other" id="other" class="width200" value="{{$other}}" placeholder="" />
        &nbsp;
        <button class="btn btn-primary" id="searchbtn">Search</button>
        </div>
    </form>
    <!--搜索栏结束-->
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="table-layout: fixed;">
      <thead>
        <tr class="lbbt">
          <td width="6%" bgcolor="#FEFFF1">订单号</td>
          <td width="6%" bgcolor="#FEFFF1">SKU</td>
          <td bgcolor="#FEFFF1">商品名称</td>
          <td bgcolor="#FEFFF1" width="5%">数量</td>
          <td width="5%" bgcolor="#FEFFF1">价格</td>
          <td width="5%" bgcolor="#FEFFF1">规格</td>
          <td  width="6%" bgcolor="#FEFFF1">工厂</td>
          <td width="6%" bgcolor="#FEFFF1">工号</td>
           <td  bgcolor="#FEFFF1" width="10%">清算日期</td>
          <td  bgcolor="#FEFFF1" width="10%">操作时间</td>
          <td width="6%" bgcolor="#FEFFF1">类型</td>
           <td width="6%" bgcolor="#FEFFF1">操作</td>
        </tr>
      </thead>
      <tbody >
       
      {{foreach from=$orderlist item=li key=key}}
     
      <tr>
        <td valign="middle"  style="position:relative;"> {{$li.order_id}} </td>
        <td valign="middle" >{{$li.goods_sku}}</td>
        <td   style="position:relative;">{{$li.skuName}}</td>
        <td valign="middle" >{{$li.goods_num}}</td>
        <td valign="middle" >{{$li.price}}</td>
        <td  class="cz">{{$li.specifications}}</td>
        <td  class="cz"> {{$li.factoryName}} </td>
        <td  class="cz">{{$li.oper}}</td>
         <td  class="cz">{{$li.settlementtime}}</td>
        <td  class="cz">{{$li.insttime}}</td>
        <td  class="cz">{{if $li.type==1}}单件定制{{/if}} {{if $li.type==2}}批量{{/if}} </td>
        <td  class="cz">{{if $usernames==$li.oper || $managers}}<a href="#" onClick="deletesanorder({{$li.id}})">删除</a> 
        {{if $li.type==2}}
        |
         <a href="javascript:void(0)" onClick="showmabangorder({{$li.id}})"><span>修改</span></a>
        {{/if}} 
        {{/if}}</td>
      </tr>
      {{/foreach}}
        </tbody>
      
    </table>
    <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
  </div>
</div>
<!-- 模态框（Modal）添加支出 -->
<form  method="post">
  <input type="hidden" name="editid" id="editid">
  <div class="modal fade" id="showmabangorder" tabindex="-1" role="dialog" aria-labelledby="sshowmabangorder" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">× </button>
          <h4 class="modal-title" id="sshowmabangorder"> 添加批量订单 </h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="right">工厂清单日期：</td>
              <td align="left"><input type="text" name="insttime" id="insttime" style="width:100px;line-height:0.4;"  onClick="WdatePicker()" >
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
          
            <tr>
              <td align="right">单号： </td>
              <td align="left"><input type="text" name="order_id" id="order_id" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input" />
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
            <tr>
              <td  align="right">SKU： </td>
              <td align="left"><input type="text" name="goods_sku" id="goods_sku" value="" maxlength="200" style="width:100px;line-height:0.4;" size=10  />
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
            <tr>
              <td  align="right">尺码： </td>
              <td align="left"><input type="text" name="specifications" id="specifications" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input" /> <font color="#FF0000">(*必填项)</font></td>
            </tr>
            <tr>
              <td align="right">数量： </td>
              <td align="left"><input type="text" name="goods_num" id="goods_num" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input" /> <font color="#FF0000">(*必填项)</font></td>
            </tr>
              <tr>
          
             <tr>
              <td align="right">工厂： </td>
              <td align="left"> <select name="fIDs" id="fIDs"  class="selection " style="width:100px;" >
          <option value="" >工厂</option>
          <option value="12" {{if 12==$fID}} selected{{/if}}>工厂1</option>
          <option value="13" {{if 13==$fID}} selected{{/if}}>工厂2</option>
        </select></td>
            </tr>
          
          </table>
          <div class="modal-footer">
          <input type="hidden" name="scanid" id="scanid" value="0">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal"> 关闭 </button>
            <button type="button" class="btn btn-primary"  onclick="atmangban()"> 提交 </button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>
</body>
</html>